<template>
  <div>
    <Management>
      <Top
        slot="top"
        @showAll="showAll"
        @search="onSearch"
        :excel="false"
        :adding="false"
      />
      <Table
        slot="body"
        :title="columns"
        :show-edit="false"
        :tableData="data"
        :current="current"
        other-txt="审核"
        :show-del="false"
        :total="total"
        @other="others"
        @changePage="changePage"
      ></Table>
    </Management>
    <Card
      :list="this.row"
      :show="showing"
      @confirm="CardConfirm"
      @cancel="CardCancel"
      @no="closeDialog"
    >
      <div name="card">ss</div>
    </Card>
  </div>
</template>
<script>
import Top from "../component/Top";
import {
  getDataByPageAndSizeUnCheck,
  Check,
  LikeSearch,
} from "@/network/Project/match";
import Table from "@/components/common/table/Table";
import Management from "@/components/common/management/Management";

import Card from "@/views/project/component/Card";

export default {
  components: { Top, Table, Management, Card },
  data() {
    const columns = [
      {
        title: "id",
        dataIndex: "id",
      },
      {
        title: "年度",
        dataIndex: "year",
      },
      {
        title: "负责人学号",
        dataIndex: "studentId",
      },
      {
        title: "项目名称",
        dataIndex: "name",
      },
      {
        title: "项目编号",
        dataIndex: "number",
      },
      {
        title: "项目负责人",
        dataIndex: "leader",
      },
      {
        title: "项目成员",
        dataIndex: "member",
      },
      {
        title: "指导老师",
        dataIndex: "teacher",
      },
      {
        title: "项目类型",
        dataIndex: "type",
      },
      {
        title: "审核结果",
        dataIndex: "check",
      },
      {
        title: "附件文件",
        dataIndex: "file",
      },
    ];
    return {
      data: [],
      columns,
      row: {},
      showing: false,
      total: 0,
      current: 1,
    };
  },
  created() {
    this.init();
  },
  methods: {
    async init(page = 1, size = 10) {
      const result = await getDataByPageAndSizeUnCheck(page, size);
      console.log(result);
      if (result.msg) {
        this.data = result.data;
        this.total = result.count;
        this.current = page;
      }
      // this.tableData = this.data;
    },
    showModel() {},
    showAll() {
      this.init();
    },
    async onSearch(value) {
      const result = await LikeSearch(value, 1, 10, 2);
      console.log(result);
      if (result.msg) {
        this.data = result.data;
        this.total = result.total;
      }
    },
    makeExcel() {},
    async CardConfirm(e) {
      this.closeDialog();
      this.$notification["success"]({
        message: "已经更新啦！",
        description: "已更新所有消息",
      });
      console.log(e);
      const res = await Check(e.id, e.check);
      console.log(res);
      this.init();
    },
    changePage(page) {
      this.init(page);
    },
    async CardCancel(e) {
      this.closeDialog();
      this.$notification["success"]({
        message: "已经更新啦！",
        description: "已更新所有消息",
      });
      const res = await Check(e.id, e.check);
      this.init();
    },
    others(e) {
      this.showing = true;
      this.row = { ...e };
    },
    closeDialog() {
      // this.isShow = false;
      // this.checking = false;
      this.showing = false;
      this.row = { time: null };
    },
  },
};
</script>

<style scoped>
</style>